//
//  BEContactController.swift
//  BEGlobalOiler
//
//  Created by KKING on 16/7/26.
//  Copyright © 2016年 Bullseye Energy pte ltd. All rights reserved.
//

import UIKit

class BEContactController: UIViewController {
    
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        view.backgroundColor = UIColor.init(red: 244/255.0, green: 245/255.0, blue: 249/255.0, alpha: 1.0)
        let phone = UserDefaults.standard.object(forKey: "phone") as? String
        
        let alertVC = UIAlertController(title: "CALL", message: phone, preferredStyle: .alert)
        
        let cancleAction = UIAlertAction(title: "Cancle", style: .cancel, handler: nil)
        let doneAction = UIAlertAction(title: "OK", style: .default) { (_) in
            
            let url = NSURL(string: "tel://\(phone)")
            UIApplication.shared.openURL(url! as URL)
        }
        
        alertVC.addAction(cancleAction)
        alertVC.addAction(doneAction)
        
        
        UIApplication.shared.keyWindow?.rootViewController!.present(alertVC, animated: true, completion: nil)
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
}
